﻿using CommonCater;
using Lufei_CaterBLL;
using Lufei_CaterModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lufei_CaterUI
{
    public partial class FrmDeskAdd : Form
    {
        public FrmDeskAdd()
        {
            InitializeComponent();
        }

        private void FrmDeskAdd_Load(object sender, EventArgs e)
        {
            LoadRoomType();
        }


        /// <summary>
        /// 获取所有房间类型
        /// </summary>
        private void LoadRoomType()
        {
            RoomInfoBLL roomInfoBLL = new RoomInfoBLL();
            List<RoomInfo> rooms = roomInfoBLL.GetRoomsByDelFlag();
            txtcmb.ValueMember = "RoomId";
            txtcmb.DisplayMember = "RoomName";
            txtcmb.DataSource = rooms;
        }



        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {

            DeskInfo desk = new DeskInfo();
            desk.RoomId = Convert.ToInt32(txtcmb.SelectedValue);
            //            insert into deskinfo(RoomId, DeskName, DeskRegion, DeskState, DelFlag, SubTime, SubBy)
            //values(@RoomId, @DeskName, @DeskRegion, @Deskstate, @DelFlag, @SubTime, @SubBy)
            desk.DeskName = txtDeskName.Text.Trim();
            desk.DeskRegion = txtDeskRegion.Text.Trim();
            desk.DeskState = 1;
            desk.DelFlag = 0;
            desk.SubTime = DateTime.Now;
            desk.SubBy = 1;

            DeskInfoBLL deskInfoBLL = new DeskInfoBLL();
           bool isInsert= deskInfoBLL.InsertDesk(desk);
            if (isInsert)
            {
                MessageBox.Show("插入成功!!!!!");
                log<FrmDeskAdd>.LogDebug("插入成功!!!!!");
            }
            else
            {
                MessageBox.Show("插入失败!!!!!");
                log<FrmDeskAdd>.LogDebug("插入失败!!!!!");
            }
        }
    }
}
